window.onload = function () {
    var oForm = document.forms[0];
    oForm.onsubmit = function () {
        var uname = this.uname.value.trim();
        var upwd = this.upwd.value.trim();
        if (!(uname.length > 0 && upwd > 0)) {
            alert("账号或密码不能为空");
            return;
        }
        $.ajax({
            url:"./account/login",
            type:"post",
            data:$("form").serialize()
        }).then(function(response){
            if(response.status == 200){
                layer.msg("登录成功");
                localStorage.setItem("userinfo",JSON.stringify(response.data));
                setTimeout(function(){
                    location = "index.html";
                },1000)
            }else{
                alert("登录失败,用户名或密码错误！")
            }
        })
        return false;
    }
}